<template>
	<view>
		<u-dropdown @open="open">
			<u-dropdown-item v-model="value1" title="舞种" @change="change" :options="options1"></u-dropdown-item>
			<u-dropdown-item v-model="value2" title="姓名" @change="change" :options="options2"></u-dropdown-item>
		</u-dropdown>
		<view v-for="(item,index) in zuiho" :key="index">
			<view style="font-size: 35rpx;font-weight: 700;text-align: center;margin-top: 52rpx;">{{item.mingzi}}小朋友</view>
			<image style="margin-left: 60rpx;margin-top: 52rpx;border-radius: 20rpx;" :src="item.toxiang"></image>
			<view style="font-size: 35rpx;font-weight: 700;margin-left: 100rpx;margin-top: 60rpx;float: left;3">性别:{{item.xinbiee}}</view>
			<view style="font-size: 35rpx;font-weight: 700;float: left;margin-top: 60rpx;margin-left: 80rpx;">入学时间:{{item.ruxue}}</view>
			
			<view style="float: left;font-size: 35rpx;font-weight: 700;margin-left: 100rpx;margin-top: 50rpx;">老师对{{item.mingzi}}的评价:</view>
			<view v-if="item.pingjia==''" style="float: left;font-weight: 700;font-size: 35rpx;margin-left: 100rpx;margin-top: 50rpx;">暂时没有老师对{{item.mingzi}}小朋友的评价</view>
			<view style="width: 85%;border: 0px solid red;float: left;margin-left: 100rpx;">
			<view v-if="item.pingjia!=''" style="margin-top: 0rpx;font-size: 35rpx;font-weight: 600;margin-left: 0rpx;">{{item.pingjia}}</view>
			</view>
			<view style="float: left;font-size: 35rpx;font-weight: 700;margin-left: 100rpx;margin-top: 20rpx;">评价时间:</view>
			<view style="width: 100%;float: left;border: 0px solid red;margin-top: 20rpx;">
				<view style="font-size: 35rpx;font-weight: 700;margin-left: 100rpx;">{{item.pingjiashijian}}</view>
			</view>
			<view style="width: 100%;float: left;height: 50rpx;"></view>
		</view>
		<view v-if="options2!=''" style="float: left;border: 0px solid red;width: 100%;">
			<view style="width: 90%;border: 0px solid red;float: left;margin-left: 60rpx;">
				<view style="font-size: 35rpx;font-weight: 600;width: 30%;float: left;">姓名:</view>
				<input v-model="jiayou" style="width: 65%;border: 1px solid #A0CFFF;border-radius: 50rpx;float: left;margin-left: -80rpx;" />
			</view>
			<view style="width: 90%;border: 0px solid red;float: left;margin-left: 60rpx;margin-top: 20rpx;">
				<view style="font-size: 35rpx;font-weight: 600;width: 30%;float: left;">性别:</view>
				<input v-model="jijiangwancheng" style="width: 65%;border: 1px solid #A0CFFF;border-radius: 50rpx;float: left;margin-left: -80rpx;" />
			</view>
			<view style="width: 90%;border: 0px solid red;float: left;margin-left: 60rpx;margin-top: 20rpx;">
				<view style="font-size: 35rpx;font-weight: 600;width: 30%;float: left;">入学时间:</view>
				<u-calendar v-model="show" :mode="mode" @change="zhende"></u-calendar>
				<view style="font-size: 40rpx;font-weight: 800;" @click="show = true"> 选择入学时间</view>
			</view>
			<button @click="haolei">修改以上数据</button>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				liuliu:"中国舞",
				jiayou:"",
				zhenhaoqiya:"",
				yuyuyu:"",
				jijiangwancheng:"",
				zuiho:[],
				qiuqiu:"",
				zhenceqiu:"",
				show: false,
				mode: 'date',
				value1: 1,
				value2: 2,
				options1: [{
						label: '街舞班',
						value: 1,
					},
					{
						label: '爵士班',
						value: 2,
					},
					{
						label: '中国舞',
						value: 3,
					}
				],
				options2: [],
				imageValue: [],
				rules: {
					// 对name字段进行必填验
					zhiwu: {
						rules: [{
							required: true,
							errorMessage: '请输入职务',
						}]
					}
				}

			}

		},
		onLoad() {
			
		},
		methods: {
			
		
			
			
			toxiang() {
				var that = this
				var par = {
					zhaop: that.imageValue[0].path,
				}
				const db = uniCloud.database();
				db.collection("tblshizi")
					.where(uni.getStorageSync("shizi")[0])
					.update(par)
					.then(function(d) {
						uni.showToast({
							title: "头像更新成功"
						})
					})
			},
			open(index) {
				var that=this
				
				// if(index==0){
					that.zhenceqiu=index
					that.change()
				// }else if(index==1){
				// 	that.changee()
				// }
			},
			change(index){
				var that=this
				console.log("Nono")
				var mert=index
				console.log(mert)
				uni.setStorageSync("wuyusil",mert)
				console.log(uni.getStorageSync("wuyusil"))
				for(var i=0;i<index;i++){
					var aaa=[i+1]
					var bbb=index
					if(aaa==bbb){
						var yyyy=that.options1[i].label
						uni.setStorageSync("zuiniubiliao",yyyy)
						that.haowuguilv(yyyy)
						console.log(yyyy)
					}
				}
				if(that.zhenceqiu==1){
				console.log(index)
				console.log(mert)
				console.log("成功了")
				that.chenggou()
				}
				
				
				
				
				
			},
			jiewubanyi(){
				var that=this;
				const db = uniCloud.database();
				db.collection("jiewuban")
				.get()
				.then(function(e){
					for(var i=0;i<e.result.data.length;i++){
						// var weewr=e.result.data[i].mingzi
						var aaa=[i]
						
						// that.options2[i].value=aaa[i]
						// that.options2[i].label=weewr
						that.options2[that.options2.length] = {
							label: e.result.data[i].mingzi,
							value: aaa
						}
					}
					
				})
				.catch(function(d){
					
				})
			},
			zhongguowu(){
			var that=this;
			const db = uniCloud.database();
			db.collection("zhongguowu")
			.get()
			.then(function(e){
				for(var i=0;i<e.result.data.length;i++){
					// var weewr=e.result.data[i].mingzi
					var aaa=[i]
					
					// that.options2[i].value=aaa[i]
					// that.options2[i].label=weewr
					that.options2[that.options2.length] = {
						label: e.result.data[i].mingzi,
						value: aaa
					}
				}
				
			})
		},
		   haowuguilv(yyyy){
			   var that=this
			if(yyyy=="中国舞"){
				that.options2.length=""
				const db = uniCloud.database();
				db.collection("zhongguowu")
				.get()
				.then(function(G){
				console.log("牛柳")
					for(var i=0;i<G.result.data.length;i++){
						
						var aaa=[i]
						that.options2[that.options2.length] = {
							label: G.result.data[i].mingzi,
							value: aaa
						}
						console.log(that.options2)
					}
					that.chenggou()
				})
			}else if(yyyy=="爵士班"){
				that.options2.length=""
				const db = uniCloud.database();
				db.collection("jueshiban")
				.get()
				.then(function(G){
					console.log("牛柳1")
					for(var i=0;i<G.result.data.length;i++){
						var aaa=[i]
						that.options2[that.options2.length] = {
							label: G.result.data[i].mingzi,
							value: aaa
						}
						console.log(that.options2)
					}
					that.chenggou()
				})
			}else if(yyyy=="街舞班"){
				that.options2.length=""
				const db = uniCloud.database();
				db.collection("jiewuban")
				.get()
				.then(function(G){
					console.log("牛柳2")
					for(var i=0;i<G.result.data.length;i++){
						var aaa=[i]
						that.options2[that.options2.length] = {
							label: G.result.data[i].mingzi,
							value: aaa
						}
						console.log(that.options2)
						
					}
					that.chenggou()
				})
			}
		},
		chenggou(){
			var that=this
			console.log("到这里了")
			var bianliang=0
			console.log(uni.getStorageSync("wuyusil"))
			for(var P=0;P<uni.getStorageSync("wuyusil");P++){
				console.log("到这里1")
				var aaabb=uni.getStorageSync("wuyusil")
				var bbsssdd=[P]
				if(aaabb==bbsssdd[0]+1){
					console.log("到这里2")
					var mbccv=that.options2[bbsssdd[0]+1].label
					that.baobei(mbccv)
				}
			}
			if(uni.getStorageSync("wuyusil")[0]==bianliang){
				var mbccv=that.options2[0].label
				that.baobei(mbccv)
			}
			
		},
		baobei(mbccv){
			var that=this
			if(uni.getStorageSync("zuiniubiliao")=="中国舞"){
				var par={
					mingzi:mbccv
				}
				const db = uniCloud.database();
				db.collection("zhongguowu")
				.where(par)
				.get()
				.then(function(zxs){
					that.zuiho=zxs.result.data
				})
			}else if(uni.getStorageSync("zuiniubiliao")=="爵士班"){
				var par={
					mingzi:mbccv
				}
				const db = uniCloud.database();
				db.collection("jueshiban")
				.where(par)
				.get()
				.then(function(zx){
					that.zuiho=zx.result.data
				})
			}else if(uni.getStorageSync("zuiniubiliao")=="街舞班"){
				var par={
					mingzi:mbccv
				}
				const db = uniCloud.database();
				db.collection("jiewuban")
				.where(par)
				.get()
				.then(function(zs){
					that.zuiho=zs.result.data
				})
			}
		},
		zhende(e){
			var that=this
				that.zhenhaoqiya=e.result
			  
		},
		haolei(){
			var that=this
			if(uni.getStorageSync("zuiniubiliao")=="中国舞"){
				var par={
					_id:that.zuiho[0]._id
				}
				var lihet={
					mingzi:that.jiayou,
					xinbiee:that.jijiangwancheng,
					ruxue:that.zhenhaoqiya
				}
				const db = uniCloud.database();
				db.collection("zhongguowu")
				.where(par)
				.update(lihet)
				.then(function(K){
					if(K.result.data!=""){
						uni.showModal({
							title:"修改成功"
						})
						that.jiayou=""
						that.jijiangwancheng=""
					}else{
						uni.showModal({
							title:"修改失败"
						})
					}
				
				})
			}else if(uni.getStorageSync("zuiniubiliao")=="街舞班"){
				var par={
					_id:that.zuiho[0]._id
				}
				var lihet={
					mingzi:that.jiayou,
					xinbiee:that.jijiangwancheng,
					ruxue:that.zhenhaoqiya
				}
				const db = uniCloud.database();
				db.collection("jiewuban")
				.where(par)
				.update(lihet)
				.then(function(KK){
					
					if(KK.result.data!=""){
						uni.showModal({
							title:"修改成功"
						})
						that.jiayou=""
						that.jijiangwancheng=""
					}else{
						uni.showModal({
							title:"修改失败"
						})
					}
				})
			}else if(uni.getStorageSync("zuiniubiliao")=="爵士班"){
				var par={
					_id:that.zuiho[0]._id
				}
				var lihet={
					mingzi:that.jiayou,
					xinbiee:that.jijiangwancheng,
					ruxue:that.zhenhaoqiya
				}
				const db = uniCloud.database();
				db.collection("jueshiban")
				.where(par)
				.update(lihet)
				.then(function(KKK){
					if(KKK.result.data!=""){
						uni.showModal({
							title:"修改成功"
						})
						that.jiayou=""
						that.jijiangwancheng=""
					}else{
						uni.showModal({
							title:"修改失败"
						})
					}
				})
			}
			
		}
		
		}
	}
</script>

<style>
	.s4 {
		font-size: 15px;
		font-weight: 600;
		float: left;
		margin-top: 30px;
		padding-left: 30px;
	}

	.s3 {
		width: 250px;
		margin-top: 25px;
		float: left;
		margin-left: -5px;
		border: 1px solid #FF9900;
		border-radius: 10px;
	}

	.s6 {
		width: 330px;
		border: 1px solid #FCBD71;
		font-size: 18px;
		margin-left: 20px;
		margin-top: 20rpx;
		text-align: center;
		line-height: 40px;
		border-radius: 40px;
		color: #FCBD71;
		height: 40px;
		font-weight: 400;
	}

	.s5 {
		font-size: 15px;
		font-weight: 700;
		margin-left: 30px;
		margin-top: 15px;
	}
</style>
